package com.jcl.recruit.resume.logic;

import com.jcl.core.utils.CollectionUtils;
import com.jcl.recruit.resume.mapper.ResumePersInfoMapper;
import com.jcl.recruit.resume.model.ResumePersInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @ClassName ResumePersInfoLogic
 * @Description TODO
 * @Author yyliu
 * @Date 2018/11/17 11:52
 * @Version 1.0
 **/
@Component
public class ResumePersInfoLogic implements ResumePersInfoMapper {

    @Autowired
    ResumePersInfoMapper resumePersInfoMapper;

    public Map<Integer, ResumePersInfo> findEntityMapByResumeIds(String corpCode, List<Integer> resumeIds) {
        Map<Integer, ResumePersInfo> dataMap = new HashMap<>();
        List<ResumePersInfo> list = resumePersInfoMapper.findListByResumeIds(corpCode, resumeIds);
        if (CollectionUtils.isNotEmpty(list)) {
            for (ResumePersInfo entity : list) {
                dataMap.put(entity.getResumeId(), entity);
            }
        }

        return dataMap;
    }

    @Override
    public List<ResumePersInfo> findListByResumeIds(String corpCode, List<Integer> resumeIds) {
        return resumePersInfoMapper.findListByResumeIds(corpCode, resumeIds);
    }

    @Override
    public Map<String, Object> findOneMap(String corpCode, Integer resumeId) {
        return resumePersInfoMapper.findOneMap(corpCode, resumeId);
    }

    @Override
    public ResumePersInfo findOne(String corpCode, Integer resumeId) {
        return resumePersInfoMapper.findOne(corpCode, resumeId);
    }

    @Override
    public int add(ResumePersInfo entity) {
        return resumePersInfoMapper.add(entity);
    }

    @Override
    public int batchDeleteByResumeIds(String corpCode, List<Integer> resumeIds) {
        return resumePersInfoMapper.batchDeleteByResumeIds(corpCode, resumeIds);
    }
}
